<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改品牌')" />
    <link href="../static/css/upload.css" th:href="@{/css/upload.css}" rel="stylesheet" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-brand-edit" th:object="${shopBrand}">
            <input name="brandId" th:field="*{brandId}" type="hidden">
            <div class="form-group">    
                <label class="col-sm-3 control-label">品牌名称：</label>
                <div class="col-sm-8">
                    <input name="brandName" th:field="*{brandName}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
				<label class="col-sm-3 control-label">品牌图标：</label>
				<div class="col-sm-8">

					<div class="file-list-box">
						<div class="file-div-box">
							<input type="hidden" id="logo" name="logo" th:value="${shopBrand.logo}">
							<div class="file-delete" onclick="deleteImage('logo')">
								<i class="fa fa-trash-o" title="删除"></i>
							</div>
							<div class="file-upload-tools" onclick="selectImage('logo')">
								<i class="fa fa-cloud-upload" title="上传"> 上传</i>
							</div>
							<img class="file-responsive" id="logoUrl" name="logoUrl"
								th:src="(${#strings.isEmpty(shopBrand.logo)}) ? @{/img/upload.png} : @{${shopBrand.logo}}"
								layer-index="0" alt="">
						</div>
					</div>
				</div>
			</div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">显示顺序：</label>
                <div class="col-sm-8">
                    <input name="sort" th:field="*{sort}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_normal_disable')}">
						<input type="radio" th:id="${dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
						<label th:for="${dict.dictCode}" th:text="${dict.dictLabel}"></label>
					</div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "shop/brand";
        $("#form-brand-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-brand-edit').serialize());
            }
        }
        
        function selectImage(imageFiled) {
			var options = {
				title: '素材库',
				width: 1500,
				height:850,
				url: ctx + "shop/plugin/material/single",
				callBack: function (index, layero) {
					var url = layero.find("iframe")[0].contentWindow.getSelections();
					if (url != "") {
						$("#" + imageFiled).val(url);
						$("#" + imageFiled + "Url").attr("src", url);
						$.modal.close(index);
					}
				}
			};
			$.modal.openOptions(options);
		}

		function deleteImage(imageFiled) {
			$("#" + imageFiled).val("");
			$("#" + imageFiled + "Url").attr("src", "/img/upload.png");
		}
    </script>
</body>
</html>